<html>
<head>
    <title>服务市场Assets批量打包工具  BY beitang.xz</title>
    <script>
        window.resizeTo(400, 650);  
        //-------init--------//
        var SH = new ActiveXObject("WScript.SHell");
        var FS = new ActiveXObject("Scripting.FileSystemObject");
    </script>
    <HTA:Application ID="oHTA" 
        Applicationname="myApp" 
        border="thin" 
        borderstyle="normal" 
        INNERBORDER="yes"
        caption="yes" 
        icon="" 
        maximizebutton="no" 
        minimizebutton="yes" 
        SHowintaskbar="yes" 
        singleinstance="yes" 
        sysmenu="no" 
        version="1.0" 
        windowstate="no" 
        scroll="no"
        SCROLLFLAT="yes" 
    >
    
    <style>
        body {
            BACKGROUND-COLOR : #FFFFFF
        }
    </style>    
</head>

<body scroll="no">
<h2>PackMe</h2>
<br/><br/>
模块列表<button onclick="selectAll();">全选</button><br/><hr/>
<div id="J_dirs">

</div>
<hr/><br/>

时间戳&nbsp;<input type="text" value="20130130" id="J_ts" />
<input type="button" value="开始打包" onclick="packAll();" />
<input type="button" value="关闭我" onclick="window.close();" />
</body>
</html>

<script>    
function selectAll() {
    var mods = document.getElementsByName("targetMod");
    for (var i = 0; i < mods.length; i++) {
        mods[i].checked = !mods[i].checked;
    }
}

function packAll() {
    var ts = document.getElementById("J_ts").value;
    var mods = document.getElementsByName("targetMod");
    for (var i = 0; i < mods.length; i++) {
        if (mods[i].checked == true)
            packOne(mods[i].value, ts);
    }
}

function packOne(mod, ts) {
    var cmd = "ki build " + mod + "/1.0/ -t " + ts;
    SH.Run(cmd, 2, false);
}

function enumCwd() {
    var dirContainer = document.getElementById("J_dirs");
    var cwd = FS.GetFolder(".");
    var s ="";
    var it = new Enumerator(cwd.subfolders);
    for (; !it.atEnd(); it.moveNext()) {
        var x=String(it.item()).split("\\");
        var fname= (x.length<1)?"":x[x.length-1];
        if (fname == 'tools' || fname == 'docs' || fname == 'utils') continue;
        s = s + "<input type='checkbox' name='targetMod' value='" + fname + "'>" + fname + "<br/>";
    }
    dirContainer.innerHTML = s;
}

enumCwd();
</script>